package cn.wolfcode.crud.web.controller;

import cn.wolfcode.crud.domain.Employee;
import cn.wolfcode.crud.service.IEmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class ResetPwdController {
    @Autowired
    private IEmployeeService employeeService;
    //共享当前账户名称
    @RequestMapping("resetPwd")
    public String resetPwd(Long id, Model model){
        Employee employee = employeeService.get(id);
        model.addAttribute("employee",employee);
        return "resetPwd/resetPwd";

    }
    //重置密码
    @RequestMapping("resetPwdUpdate")
    public String resetPwdUpdate(Long id,String newPassword){
        employeeService.updatePassword(id,newPassword);
        return "forward:employee/list.do";

    }
}
